package com.xinwei.leetcode.二叉树;

// https://leetcode-cn.com/problems/kth-smallest-element-in-a-bst/
public class _230_二叉搜索树中第K小的元素 {
    int i = 0;
    boolean a = true;
    int re = 0;
    public int kthSmallest(TreeNode root, int k) {
        if (root == null) return 0;
        if (a) kthSmallest(root.left, k);
        if (++i == k) {
            a = false;
            return re = root.val;
        }
        System.out.println(re);
        if (a) kthSmallest(root.right, k);
        return re;
    }
}
